﻿/*
* 作 者: 王冬冬
* 公 司: 墨宇天城
* 创建时间: 2016/3/23 17:29:24
* 说明:  
*/

using UnityEngine;
using System.Collections;
using System.Collections.Generic;
using UnityEngine.UI;

public class ShowWanning : MonoBehaviour
{
    private bool isboo = true;
    private Image imagebig;
    private Image imageSmall;
    void Awake()
    {
        imagebig = this.transform.Find("img0").GetComponent<Image>();
        imageSmall = this.transform.Find("img1").GetComponent<Image>();
    }
    public IEnumerator ReplaceImg()
    {
        while (true)
        {
            if (isboo)
            {
                imageSmall.gameObject.SetActive(true);
                imagebig.gameObject.SetActive(false);
                isboo = false;
            }
            else
            {
                imageSmall.gameObject.SetActive(false);
                imagebig.gameObject.SetActive(true);
                isboo = true;
            }
            yield return new WaitForSeconds(0.5f);
        }
    }
    public void StartRandomImg()
    {
        imagebig.gameObject.SetActive(true);
        imageSmall.gameObject.SetActive(true);
        int random = Random.Range(0, 5);
        imagebig.overrideSprite = ResoucesSprite("Wanning/WanningBig" + random);
        imageSmall.overrideSprite = ResoucesSprite("Wanning/WanningSmall" + random);
        StartCoroutine(ReplaceImg());
        
    }
    public void StopCor()
    {
        StopAllCoroutines();
        imagebig.gameObject.SetActive(false);
        imageSmall.gameObject.SetActive(false);
    }
    Sprite ResoucesSprite(string path)
    {
        return Resources.Load(path, typeof(Sprite)) as Sprite;
    }
}